home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / apps / 186 / applic / initpntr.pas < prev    next >
Pascal/Delphi Source File  |  1987-10-13  |  2KB  |  70 lines

  1. {$S1}   {1 K stack}
  2. PROGRAM InitializePrinter;
  3.   {To minimize the size of the .PRG, compile with debug off, stack checking
  4.   off, and range checking off.}
  5.   CONST
  6.     FileName = 'A:\PRTSTUPA.INF';
  7.   TYPE
  8.     T2 = PACKED ARRAY [1..80] OF char;
  9.     T1 = PACKED ARRAY [1..512] OF char;
  10.   VAR
  11.     junk : long_integer;
  12.     f : T2;
  13.     Handle : integer;
  14.     Count : long_integer;
  15.     Buffer : T1;
  16.     NBytes : long_integer;
  17.     i : integer;
  18.     ch : byte;
  19.     S : string;
  20.     ch2 : char;
  21.     j : long_integer;
  22.  
  23.   FUNCTION Out(x : byte) : long_integer;
  24.     GEMDOS( $05 );
  25.  
  26.   FUNCTION Open
  27.      (VAR FilePtr : T2;
  28.              mode : integer)
  29.                   : integer;
  30.     GEMDOS( $3D);
  31.  
  32.     FUNCTION Read
  33.          (Handle : integer;
  34.            count : long_integer;
  35.          VAR buf : T1)
  36.                  : long_integer;
  37.       GEMDOS( $3F);
  38.  
  39.   FUNCTION ConIn : long_integer;
  40.     GEMDOS ($01);
  41.  
  42.   BEGIN      {initializeprinter}
  43.     S := FileName;
  44.     FOR i := 1 TO LENGTH(S)DO
  45.       F[i] := S[i];
  46.     F[LENGTH(S) + 1] := CHR(0);
  47.     WriteLn('Initializing printer.');
  48.     WriteLn('You have 5 seconds to provide a new');
  49.     WriteLn('last character for the set up file name.  [A - Z]');
  50.     {5 second delay}
  51.     j := 1;
  52.     REPEAT
  53.       j := j + 1;
  54.     UNTIL j > 388500;
  55.     IF KeyPress THEN
  56.       BEGIN
  57.         ReadLn(ch2);
  58.         F[11] := ch2;
  59.       END;
  60.     Handle := Open(F,0);
  61.     IF Handle > 5 THEN
  62.       BEGIN
  63.         NBytes := Read(Handle,512,Buffer);
  64.         {Send set up commands to printer}
  65.         REWRITE(Output,'PRN:');
  66.         FOR i := 1 TO INT(NBytes) DO
  67.           Write(Output,Buffer[i]);
  68.       END;
  69.   END.
  70.